﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace android_charge.Utils
{
    public class ProcessWrapper
    {
        public Process scrcpy;

        public bool isDoubleClk = false;

        public static ConcurrentDictionary<Process, ProcessWrapper> WrMap = new ConcurrentDictionary<Process, ProcessWrapper>();

        public static ConcurrentDictionary<ProcessWrapper, MoveListener> LsMap = new ConcurrentDictionary<ProcessWrapper, MoveListener>();


        public static ProcessWrapper start(string arg, bool isDoubleClk)
        {
            var processWrapper = new ProcessWrapper();
            processWrapper.isDoubleClk = isDoubleClk;
            var processStartInfo = new ProcessStartInfo("scrcpy")
            {
                Arguments = arg,
                CreateNoWindow = true,
                UseShellExecute = false,
                RedirectStandardOutput = true,
                RedirectStandardError = true,
                RedirectStandardInput = true,
            };
            processWrapper.scrcpy = Process.Start(processStartInfo);
            WrMap[processWrapper.scrcpy] = processWrapper;
            return processWrapper;
        }


        public static ProcessWrapper GetProcessWr(Process process)
        {
            return WrMap[process];
        }
    }
}
